package com.elink.enginerring.video.service;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.elink.enginerring.common.BaseCo;
import com.elink.enginerring.common.ErrorType;
import com.elink.enginerring.common.Pagination;
import com.elink.enginerring.util.JSONUtil;
import com.elink.enginerring.video.dao.PlannHierMapper;
import com.elink.enginerring.video.entity.PlannHier;
@Service
public class PlannHierService  implements IPlannHierService{
	@Autowired
	private PlannHierMapper plannHierMapper;

	@Override
	public Map<String, Object> getList(BaseCo co) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list", plannHierMapper.selectList(co));
		map.put("pagination", new Pagination(co, plannHierMapper.selectCount(co)));
		return JSONUtil.getJSON(ErrorType.SUCCESS, map);
	}

	@Override
	public Map<String, Object> add(PlannHier ph) {
		ph.setCreateTime(new Date());
		ph.setPublishStatus(1);//后台添加默认发布,不知是否以后需要单独的发布前台才能够看到
		ph.setAuthStatus(1);//后台添加不需要审核
		ph.setDeleteStatus(0);//默认未删除
		plannHierMapper.insertSelective(ph);
		return JSONUtil.getJSON(ErrorType.SUCCESS);
	}

	@Override
	public Map<String, Object> modify(PlannHier ph) {
		ph.setUpdateTime(new Date());
		plannHierMapper.updateByPrimaryKeySelective(ph);
		return JSONUtil.getJSON(ErrorType.SUCCESS);
	}

	@Override
	public void del(String ids) {
		plannHierMapper.del(ids);
	}
}
